/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SLE_SSAP_CLIENT_PARCEL_H
#define SLE_SSAP_CLIENT_PARCEL_H

#include <cstdint>
#include <memory>
#include "parcel.h"
#include "sle_ssap_client_config.h"
#include "sle_ssap_common_parcel.h"
#include "sle_error_code.h"

namespace OHOS {
namespace NearLink {
namespace SleStandard {
class SsapClientFindStructure : public Parcelable {
public:
    SsapClientFindStructure() = default;
    explicit SsapClientFindStructure(const ClientFindStructure &param);
    ~SsapClientFindStructure() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapClientFindStructure *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToClientFindStructure(ClientFindStructure &param) const;
    static SleErrorCode CheckClientFindStructure(const ClientFindStructure &param);

public:
    uint8_t type_;
    uint16_t startHandle_;
    uint16_t endHandle_;
    Uuid uuid_;
    uint8_t reserve_;
};

class SsapClientReadReqByUUID : public Parcelable {
public:
    SsapClientReadReqByUUID() = default;
    explicit SsapClientReadReqByUUID(const ClientReadReqByUUID &param);
    ~SsapClientReadReqByUUID() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapClientReadReqByUUID *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToClientReadReqByUUID(ClientReadReqByUUID &param) const;
    static SleErrorCode CheckClientReadReqByUUID(const ClientReadReqByUUID &param);

public:
    uint8_t type_;
    uint16_t startHandle_;
    uint16_t endHandle_;
    Uuid uuid_;
};

class SsapClientHandleValue : public Parcelable {
public:
    SsapClientHandleValue() = default;
    explicit SsapClientHandleValue(const ClientHandleValue &value);
    explicit SsapClientHandleValue(const ClientWriteParam &value);
    ~SsapClientHandleValue() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapClientHandleValue *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToClientHandleValue(ClientHandleValue &value) const;
    void ConvertToClientWriteParam(ClientWriteParam &param) const;
    static SleErrorCode CheckClientWriteParam(const ClientWriteParam &param);

public:
    uint16_t handle_;
    uint8_t type_;
    uint16_t length_;
    std::unique_ptr<uint8_t[]> data_;
};

class SsapClientFindServiceRes : public Parcelable {
public:
    SsapClientFindServiceRes() = default;
    explicit SsapClientFindServiceRes(const ClientFindServiceRes &result);
    ~SsapClientFindServiceRes() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapClientFindServiceRes *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToClientFindServiceRes(ClientFindServiceRes &value) const;

public:
    uint16_t startHandle_;
    uint16_t endHandle_;
    Uuid uuid_;
};

class SsapClientFindPropertyRes : public Parcelable {
public:
    SsapClientFindPropertyRes() = default;
    explicit SsapClientFindPropertyRes(const ClientFindPropertyRes &result);
    ~SsapClientFindPropertyRes() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapClientFindPropertyRes *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToClientFindPropertyRes(ClientFindPropertyRes &value) const;

public:
    uint16_t handle_;
    uint32_t operateIndication_;
    Uuid uuid_;
    uint8_t descriptorsCount_;
    std::unique_ptr<uint8_t[]> descriptorsType_;
};
} // SleStandard
} // NearLink
} // OHOS

#endif // SLE_SSAP_CLIENT_PARCEL_H